package tuiLayer;

import controlLayer.*;
import modelLayer.*;
import java.util.Scanner;

public class MainMenuUI {
    private PersonUI person;
    private DvdUI dvd;
    private LoanUI loan;
    
    public MainMenuUI () {
        person = new PersonUI();
        dvd = new DvdUI();
        loan = new LoanUI();
    } 
    
    public void start() {
        mainMenu();
    } 
    
    /**
     * Main menu methods
     **/
    private void mainMenu() {
        boolean stop = false;
        
        while(!stop) {
            int choice = writeMainMenu();
            
            switch(choice) {
            case 1 : person.friendsMenu();
                break;
            case 2 : dvd.dvdsMenu();
                break;
            case 3 : loan.loanMenu();
                break;
            case 0 : System.out.println("The system will stop");
                     stop = true;
                break;
            default : System.out.println("Invalid command");
                      MainMenuUI.pause();
                      stop = true;
                break;
            }
        }
    }
    
    private int writeMainMenu() {
        Scanner keyboard = new Scanner(System.in);
        System.out.println("\f*** Main Menu ***");
        System.out.println("1. Persons");
        System.out.println("2. DVDs ");
        System.out.println("3. Loan ");
        System.out.println("0. Close ");
        System.out.println("\n Type your choice (numeric)");
        
        int choice = keyboard.nextInt();
        
        return choice;
    }
    
    public static void pause()
    {
         Scanner keyboard = new Scanner(System.in);
         System.out.println("Enter to continue");
         String address = keyboard.nextLine();
    }
    
}